package com.limao.CacheManager;

import com.Hazelcast.Cache;
import com.Hazelcast.CacheFactory;
import com.limao.Tool.CacheClass;
import com.limao.cache.BasicModule;

public class SessionCacheManager  extends BasicModule{

	private static SessionCacheManager instance;

	public static SessionCacheManager getInstance() {
		return instance;
	}

	private Cache<String, String> Sesinon_ManagerCache;

	public SessionCacheManager() {
    	super("SessionCacheManager");
    	Sesinon_ManagerCache = CacheFactory.createCache("cd_SessionCache",10*1024*1024,2*3600*1000);
	}

    @Override
	public void initialize() {
        super.initialize();
        instance=this;
    }
    
    public void ClearObjectCache(String id)
    {
    	if(CacheClass.isEmpty(id)) return;
    	String tmp = Sesinon_ManagerCache.get(id);
    	if(tmp!=null)
    		Sesinon_ManagerCache.remove(id);

    } 
    
    public void PutSessionCache(String sessionId,String userid)
    {
    	Sesinon_ManagerCache.put(sessionId,userid);

    }   
    
    public String GetSessionCache(String sessionId)
    {
    	if(CacheClass.isEmpty(sessionId)) return null;
    	return Sesinon_ManagerCache.get(sessionId);//userid

    }  
	
}
